<?php $this->load->view('common/cms-head'); ?>
<article id="content">
    <div class="pgwrapper">
    <div class="w960 bg1 p15 bx_shw">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td width="20%" style="border-right: 2px solid #e5e5e5;" valign="top">
		<?php $this->load->view('enterprises/leftnavCMS'); ?>
		</td>
		<td width="80%" valign="top" style="padding:5px;"><form enctype="multipart/form-data"
				action="/updateCoupon" method="POST">
				<table width="100%" border="0" cellpadding="5" cellspacing="0"
					style="padding: 0px 30px;">
					<input type="hidden" value="<?php echo $coupon_id;?>" id="coupon_id" name="coupon_id">
					<input type="hidden" value="<?php echo $couponDetailsArray[0]['coupon_image'];?>" id="coupon_old_img" name="coupon_old_img">
					<tr>
						<td class="txt-blck">Select Store:</td>
						<td><select id="code_store" name="code_store[]" multiple="multiple" style="width: 200px;height:100px;"
							onChange="storeredirectCheck()" class="setBgInput">
							<?php foreach ($allStoresArray as $temp){ ?>
								<option <?php if (in_array($temp['store_id'], $couponStoresArray)){ echo "selected"; }?> value="<?php echo $temp['store_id']; ?>">
								<?php echo $temp['store_name']; ?>
								</option>
								<?php } ?>
						</select></td>
					</tr></td>
					</tr>
					<tr>
						<td class="txt-blck" width="30%">coupon Title:</td>
						<td width="70%"><input type="text" onblur="makeURLName(this)"
							value="<?php echo $couponDetailsArray[0]['coupon_name'];?>"
							name="coupon_name" id="coupon_name" class="setBgInput"
							  />
						</td>
					</tr>
					<tr>
						<td class="txt-blck" width="30%">coupon Code:</td>
						<td width="70%"><input type="text"
							value="<?php echo $couponDetailsArray[0]['coupon_code'];?>"
							name="coupon_code" id="coupon_code" class="setBgInput"
							  />
						</td>
					</tr>
					<tr>
						<td class="txt-blck">coupon Status:</td>
						<td><select id="coupon_status" name="coupon_status" style="width:90px;padding-top:5px;" class="setBgInput">
								<option value="no status">No Status</option>
								<option 
								<?php if ($couponDetailsArray[0]['coupon_status']=="Process"){echo "selected"; }?> value="Process">Process</option>
								<option value="Yes"
								<?php if ($couponDetailsArray[0]['coupon_status']=="Yes"){echo "selected"; }?>>Yes</option>
								<option value="No"
								<?php if ($couponDetailsArray[0]['coupon_status']=="No"){echo "selected"; }?>>No</option>
						</select></td>
					</tr>
					<tr>
						<td class="txt-blck">Coupon Off By:</td>
						<td width="70%"><input type="text" value="<?php echo $couponDetailsArray[0]['coupon_off_by'];?>" name="coupon_offby"
							id="coupon_offby" class="setBgInput" style="width:100px;"   />
						</td>
					</tr>
					<tr>
						<td class="txt-blck">Coupon Off In:</td>
						<td><select id="coupon_offin" name="coupon_offin" style="width:90px;padding-top:5px;" class="setBgInput">
								<option <?php if($couponDetailsArray[0]['coupon_off_in']=='Rupees'){ echo 'selected';}?>
								 value="Rupees">Rupees</option>
								<option <?php if($couponDetailsArray[0]['coupon_off_in']=='Percentage'){ echo 'selected';}?>
								value="Percentage">Percentage</option>
						</select></td>
					</tr>
					<tr>
						<td class="txt-blck" width="30%">Coupon Image	:</td>
						<td width="70%"><input type="file" name="coupon_image"
							id="coupon_image" class="setBgInput"   />
						</td>
					</tr>
					<tr>
						<td class="txt-blck" width="30%">Coupon Offer Only	:</td>
						<td width="70%"><select id="coupon_offer_only" name="coupon_offer_only" style="width:90px;padding-top:5px;" class="setBgInput">
                                <option value="No"
                                <?php if ($couponDetailsArray[0]['coupon_offer_only']=="No"){echo "selected"; }?>>No</option>
								<option value="Yes"
								<?php if ($couponDetailsArray[0]['coupon_offer_only']=="Yes"){echo "selected"; }?>>Yes</option>
						</select>
						</td>
					</tr>
					<tr>
						<td class="txt-blck">coupon Type:</td>
						<td><select id="coupon_type" name="coupon_type" style="width:90px;padding-top:5px;" class="setBgInput">
                                <option value="Offer"
								<?php if ($couponDetailsArray[0]['coupon_type']=="Offer"){echo "selected"; }?>>Offers</option>
								<option value="TopCpn"
								<?php if ($couponDetailsArray[0]['coupon_type']=="TopCpn"){echo "selected"; }?>>Top Coupons</option>
								<option value="FeaturedCpn"
								<?php if ($couponDetailsArray[0]['coupon_type']=="FeaturedCpn"){echo "selected"; }?>>Featured Coupons</option>
								<option value="Cpn"
								<?php if ($couponDetailsArray[0]['coupon_type']=="Cpn"){echo "selected"; }?>>Coupons</option>
						</select></td>
					</tr>
					<tr>
						<td class="txt-blck">Coupon Category:</td>
						<td><select id="coupon_cat" name="coupon_cat" style="width:90px;padding-top:5px;" class="setBgInput">
                                <option value="0">None</option>
                                <?php foreach($allCategoriesArray as $temp){ ?>
								<option value="<?php echo $temp['category_id']; ?>"
								<?php if ($couponDetailsArray[0]['coupon_category']==$temp['category_id']){echo "selected"; }?>><?php echo $temp['category_name']; ?></option>
                                <?php } ?>
						</select></td>
					</tr>
					<tr>
						<td valign="top" class="txt-blck">coupon Description:</td>
						<td><textarea style="width: 450px; height: 300px;" class="setBgInput"
								id="coupon_description" name="coupon_description">
								<?php echo $couponDetailsArray[0]['coupon_description'];?>
								</textarea></td>
					</tr>
					<tr>
						<td valign="top" class="txt-blck">Coupon Start Date:</td>
						<td><input type="text" name="coupon_startdate" id="coupon_startdate" style="width: 100px"
							onfocus="javascript:NewCssCal('coupon_startdate','yyyymmdd','arrow',false,'24',false);"
							value="<?php  echo $couponDetailsArray[0]['coupon_startdate'];?>"
							readonly class="setBgInput" /> (yyyy/mm/dd)</td>
					</tr>
					<tr>
						<td valign="top" class="txt-blck">Coupon Expire Date:</td>
						<td><input type="text" name="coupon_expiredate" id="coupon_expiredate" style="width: 100px"
							onfocus="javascript:NewCssCal('coupon_expiredate','yyyymmdd','arrow',false,'24',false);"
							value="<?php  echo $couponDetailsArray[0]['coupon_expiredate']; ?>"
							readonly class="setBgInput" /> (yyyy/mm/dd)</td>
					</tr>
					<tr>
						<td valign="top" class="txt-blck" id="affurl_title">Coupon Affliate URL:</td>
						<td>
							<div id="check_deep">
								<input type="checkbox" name="editURL"  id="editURL" value="1"
									onclick="activeCAU();selectTrack();" /> Deep Link URL
							</div>
						<!--  
							<div id="radioDiv" style="display:none;">
								<input type="radio" name="omg" id="omg" onclick="insertTrack(1)" /> OMG
								<input type="radio" name="tc" id="tc" onclick="insertTrack(2)" /> Trootrac
								<input type="radio" name="ty" id="ty" onclick="insertTrack(3)" /> Tyroo
							</div>-->	
							
							<div id="affliateURLDiv">
                               
                                <input type="text" name="coupon_affilateurl" id="coupon_affilateurl" style="width: 320px" value="<?php  echo $couponDetailsArray[0]['coupon_affilateurl'];?>" readonly class="setBgInput" />
							</div>
							
							<div id="utmsrc" style="display:none;">
								<input type="text" value="<?php  if(isset($couponDetailsArray[0]['store_utmsource'])){ echo $couponDetailsArray[0]['store_utmsource']; } ?>" name="utmSource" id="utmSource" style="width: 400px" 
								 />
							</div>
							
						</td>
					</tr>
					
					<tr>
						<td></td>
						<td><input type="submit" name="code_submit" value="Submit" class="btn_bg" /></td>
					</tr>
				</table>
			</form>
		</td>
	</tr>
</table>
</div>
</div>
</article>
<div class="clr-both spacer-10">&nbsp;</div>
<?php $this->load->view('common/cms-footer'); ?>
<script>
function activeCAU() {
	if (document.getElementById("editURL").checked) {
		document.getElementById("coupon_affilateurl").removeAttribute(
				"readonly")
	} else {
		document.getElementById("coupon_affilateurl").setAttribute("readonly",
				"readonly")
	}
}
function validateForm(){
	var s = document.getElementById('code_store').value;
	if(s==""){
	alert("You must choose a store.");
	document.getElementById('code_store').focus();
	return false;
	}
	var x = document.getElementById('coupon_name').value;
	if(x==""){
	alert("Coupon Title must be filled out.");
	return false;
	}
	var o = document.getElementById('coupon_offby').value;
	if(o==""){
	alert("Coupon off by must be filled out.");
	return false;
	}
}
	
</script>
